﻿<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BuddyTracker.ViewModel.Helpers"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:maps="using:Windows.UI.Xaml.Controls.Maps"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    xmlns:toolkit="using:Kinnara.Xaml.Controls" 
    x:Class="BuddyTracker.MainPage"
    mc:Ignorable="d"
    DataContext="{Binding Source={StaticResource Locator}, Path=Main}"
    x:Name="PageMainPage">

    <interactivity:Interaction.Behaviors>
        <core:EventTriggerBehavior EventName="Loaded">
            <core:InvokeCommandAction Command="{Binding OnNavigatedToCommand, Mode=OneWay}"/>
        </core:EventTriggerBehavior>
    </interactivity:Interaction.Behaviors>

    <Page.Resources>
        <local:RadioButtonToIntConverter x:Key="RadioButtonToIntConverter" />
    </Page.Resources>
    <Page.Background>

        <ImageBrush ImageSource="ms-appx:///Assets/bcg.png" Opacity="0.15" Stretch="UniformToFill" />

    </Page.Background>

    <Pivot x:Uid="MainPivot">
        <PivotItem x:Uid="PivotLocation" Margin="10,0,10,0">
            <Grid Margin="10,-7,10,0" VerticalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="4*" />
                    <RowDefinition Height="24*" />
                </Grid.RowDefinitions>
                <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Grid.Row ="0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="2.5*" />
                        <RowDefinition Height="6*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" TextWrapping="Wrap" x:Uid="LatitudeLabel" VerticalAlignment="Top" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Grid.Row="1" Grid.Column="0" Text="{Binding TextLatitude}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Style="{StaticResource BaseTextBlockStyle}" FontSize="22"/>
                    <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" TextWrapping="Wrap" TextAlignment="Right" x:Uid="LongitudeLabel" VerticalAlignment="Top" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding TextLongitude}" TextAlignment="Right" HorizontalAlignment="Right" TextWrapping="Wrap" VerticalAlignment="Top" Style="{StaticResource BaseTextBlockStyle}" FontSize="22"/>
                    <TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" TextWrapping="Wrap" x:Uid="LocationLabel" VerticalAlignment="Top" Style="{StaticResource ControlHeaderTextBlockStyle}" Visibility="Collapsed"/>
                </Grid>
                <Grid Margin ="-10,-25,-10,12" VerticalAlignment="Stretch" Grid.Row="1">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="14*"/>
                        <RowDefinition Height="2.7*"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <maps:MapControl Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Grid.RowSpan="2" FontSize="24" MapServiceToken="V3Xx3dJJd5HRqv9W9TmYyw" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin ="0,10,0,0" x:Name="CurrentMap" ZoomLevel="1"/>
                    <Button Grid.Row="1" Grid.Column="0" x:Uid="PostLocationButton" Command="{Binding PostLocationCommand}" IsEnabled="{Binding ActionsAllowed}" HorizontalAlignment="Stretch" Margin="5,0,5,0" Background="#4C5A5A5A"/>
                    <Button Grid.Row="1" Grid.Column="1" x:Uid="RefreshButton" Command="{Binding RefreshCommand}" IsEnabled="{Binding ActionsAllowed}" HorizontalAlignment="Stretch" Margin="5,0,5,0" Background="#4C5A5A5A" />
                    
                </Grid>
            </Grid>
        </PivotItem>
        <PivotItem x:Uid="PivotTwitter" Margin="10,0,10,0">
            <Grid Margin="10,0,10,0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.75*"/>
                    <RowDefinition Height="1.5*"/>
                    <RowDefinition Height="1.5*"/>
                    <RowDefinition Height="1.7*"/>
                    <RowDefinition Height="10*"/>
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" HorizontalAlignment="Stretch" TextWrapping="Wrap" Text="{Binding StatusMessage}" VerticalAlignment="Top" Style="{StaticResource ControlHeaderTextBlockStyle}" />
                <Button Grid.Row="1" HorizontalAlignment="Stretch" Command="{Binding LoginTwitterCommand}" IsEnabled="{Binding LoginEnabled}" x:Uid="ButtonTwitterLogin" VerticalAlignment="Top" />
                <Button Grid.Row="2" HorizontalAlignment="Stretch" x:Uid="ButtonTwitterLogout" TabIndex="1" Command="{Binding LogOutTwitterCommand}" IsEnabled="{Binding LogoutEnabled}" VerticalAlignment="Top"/>
                <TextBox Grid.Row="3" InputScope="Search" x:Uid="txtTwitterFriendName" IsEnabled="{Binding LogoutEnabled}" x:Name="txtTwitterFriendName" TabIndex="0" Text="{Binding SearchBoxText, Mode=TwoWay}" AcceptsReturn="False">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="KeyDown">
                            <core:InvokeCommandAction
                                    Command="{Binding FollowCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                </TextBox>

                <ListBox Grid.Row="4" ItemsSource="{Binding TwitterUsers}" Background="Transparent" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                    <ListBox.ItemContainerStyle>
                        <Style TargetType="ListBoxItem">
                            <Setter Property="HorizontalContentAlignment" Value="Stretch"></Setter>
                        </Style>
                    </ListBox.ItemContainerStyle>
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid HorizontalAlignment="Stretch" Background="Transparent">
                                <toolkit:ContextMenuService.ContextMenu>
                                    <MenuFlyout>
                                        <MenuFlyoutItem x:Uid="DeleteOption" Command="{Binding Mode=OneWay, ElementName=PageMainPage, Path = DataContext.UnfollowCommand}" CommandParameter="{Binding ScreenName}"/>
                                        <MenuFlyoutItem x:Uid="ShowBuddyOption" Command="{Binding Mode=OneWay, ElementName=PageMainPage, Path = DataContext.ShowBuddy}" CommandParameter="{Binding ScreenName}"/>
                                    </MenuFlyout>
                                </toolkit:ContextMenuService.ContextMenu>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="35" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="35" />
                                </Grid.RowDefinitions>
                                <Image HorizontalAlignment="Left" Width="35" Height="35" Grid.Column="0" Source="ms-appx:///Assets/Twitter_logo_blue.png" />
                                <TextBlock HorizontalAlignment="Stretch" Grid.Column="1" TextWrapping="NoWrap" Text="{Binding ScreenName}" VerticalAlignment="Center" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Margin="12,0,0,0" />
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>

            </Grid>
        </PivotItem>
        <PivotItem x:Uid="PivotSettings" Margin="10,0,10,0">
            <ScrollViewer HorizontalScrollMode="Disabled">
                <StackPanel Orientation="Vertical" Margin="10,0,0,0">
                    <ToggleSwitch x:Uid="LocationToggle" IsOn="{Binding LocationAllowed, Mode=TwoWay, FallbackValue=True}"/>
                    <TextBlock x:Uid="tbPostUpdates" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <StackPanel Orientation ="Horizontal">
                        <RadioButton GroupName="AutomaticUpdates" x:Uid="radioManual" IsChecked="{Binding Path=SettingAutomaticPosting, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" />
                        <RadioButton GroupName="AutomaticUpdates" x:Name="AutoUpdates" x:Uid="radioAutomatic" IsChecked="{Binding Path=SettingAutomaticPosting, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}" />
                    </StackPanel>

                    <TextBlock x:Uid="tbAutomaticPostInterval" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <RadioButton GroupName="AutomaticUpdatesInterval" IsEnabled="{Binding Mode=OneWay, ElementName=AutoUpdates, Path = IsChecked}" x:Uid="radioFiveMinutes" IsChecked="{Binding Path=SettingAutomaticPostingInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" Margin="0,-8,0,-14"/>
                    <RadioButton GroupName="AutomaticUpdatesInterval" IsEnabled="{Binding Mode=OneWay, ElementName=AutoUpdates, Path = IsChecked}" x:Uid="radioFifteenMinutes" IsChecked="{Binding Path=SettingAutomaticPostingInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}"/>
                    <RadioButton GroupName="AutomaticUpdatesInterval" IsEnabled="{Binding Mode=OneWay, ElementName=AutoUpdates, Path = IsChecked}" x:Uid="radioThirtyMinutes" IsChecked="{Binding Path=SettingAutomaticPostingInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=2, Mode=TwoWay}" Margin="0,-13,0,0"/>

                    <TextBlock x:Uid="tbBuddyTrackerRefreshInterval" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <RadioButton GroupName="BuddyTrackerInterval" x:Uid="radioManual"  IsChecked="{Binding Path=SettingBuddyTrackerInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" Margin="0,-8,0,-14"/>
                    <RadioButton GroupName="BuddyTrackerInterval" x:Uid="radioThirtySeconds"  IsChecked="{Binding Path=SettingBuddyTrackerInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}" />
                    <RadioButton GroupName="BuddyTrackerInterval" x:Uid="radioFiveMinutes" IsChecked="{Binding Path=SettingBuddyTrackerInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=2, Mode=TwoWay}" Margin="0,-15,0,-14" />
                    <RadioButton GroupName="BuddyTrackerInterval" x:Uid="radioFifteenMinutes" IsChecked="{Binding Path=SettingBuddyTrackerInterval, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=3, Mode=TwoWay}" Margin="0"/>

                    <TextBlock x:Uid="tbMapStyle" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <StackPanel Orientation ="Horizontal">
                        <RadioButton GroupName="Map" x:Uid="MapStyleNormal" IsChecked="{Binding Path=MapType, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" />
                        <RadioButton GroupName="Map" x:Uid="MapStyleSatellite" IsChecked="{Binding Path=MapType, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}" Margin="-30,0,0,0"/>
                    </StackPanel>

                    <StackPanel Orientation="Horizontal" Margin="0,-10,0,0">
                        <RadioButton GroupName="Map" x:Uid="MapStyleHybrid" IsChecked="{Binding Path=MapType, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=2, Mode=TwoWay}" />
                        <RadioButton GroupName="Map" x:Uid="MapStyleTerrain" IsChecked="{Binding Path=MapType, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=3, Mode=TwoWay}" Margin="-30,0,0,0"/>
                        <RadioButton GroupName="Map" x:Uid="MapStyle3D" IsChecked="{Binding Path=MapType, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=4, Mode=TwoWay}" Margin="-40,0,0,0"/>
                    </StackPanel>
                    
                    <TextBlock x:Uid="tbEncoder" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <StackPanel Orientation ="Horizontal">
                        <RadioButton GroupName="Encoder" x:Uid="radioEncoderHex" IsChecked="{Binding Path=SettingEncoder, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}" />
                        <RadioButton GroupName="Encoder" x:Uid="radioEncoderText" IsChecked="{Binding Path=SettingEncoder, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" Margin="-65,0,0,0"/>
                    </StackPanel>
                    <RadioButton x:Name="AesRadioButton" GroupName="Encoder" x:Uid="radioEncoderAes" IsChecked="{Binding Path=SettingEncoder, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=2, Mode=TwoWay}" Margin="0,-10,0,0"/>

                    <TextBox MaxLength="32" x:Uid="txtKeyPhrase" IsEnabled="{Binding Mode=OneWay, ElementName=AesRadioButton, Path = IsChecked}" TabIndex="0" Text="{Binding KeyPhraseText, Mode=TwoWay}" AcceptsReturn="False" Margin="0,10,20,10" />
                        
                    <TextBlock x:Uid="tbLanguage" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}" Margin="0,0,10,15"/>

                    <TextBlock x:Uid="LanguageOverride" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <RadioButton GroupName="Language" x:Uid="radioPhoneLanguage" Command="{Binding LanguageChangeCommand}" IsChecked="{Binding Path=SettingLanguage, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=0, Mode=TwoWay}" Margin="0,-8,0,-14"/>
                    <RadioButton GroupName="Language" x:Uid="radioEnglish" Command="{Binding LanguageChangeCommand}" IsChecked="{Binding Path=SettingLanguage, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=1, Mode=TwoWay}" />
                    <RadioButton GroupName="Language" x:Uid="radioSerbianLatin" Command="{Binding LanguageChangeCommand}" IsChecked="{Binding Path=SettingLanguage, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=2, Mode=TwoWay}" Margin="0,-15,0,0"/>
                    <!-- > <RadioButton GroupName="Language" x:Uid="radioSerbianCyr" Command="{Binding LanguageChangeCommand}" IsChecked="{Binding Path=SettingLanguage, Converter={StaticResource RadioButtonToIntConverter}, ConverterParameter=3, Mode=TwoWay}" Margin="0,0,0,14" /> </!-->

                    <HyperlinkButton NavigateUri="http://nmilosev.svbtle.com/flwr-privacy" x:Uid="PrivacyPolicy" Margin="0,0,0,40" />
                    
                </StackPanel>

            </ScrollViewer>
        </PivotItem>

        <PivotItem x:Uid="PivotAbout" Margin="10,0,10,0">
            <ListBox  Margin="0,-5,0,5" Background="Transparent" SelectionMode="Single" ScrollViewer.VerticalScrollBarVisibility="Hidden">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    </Style>
                </ListBox.ItemContainerStyle>
                <StackPanel Margin="0,-15,0,5">
                    <TextBlock Text="Follower" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="34" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock Text="1.1.1.0" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Text="Nemanja Milošević" TextWrapping="Wrap"  Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Text="@nmilosev" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Text="nmilosev@live.com" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Text="nmilosevnm@gmail.com" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <TextBlock Text="nmilosev@alfasoft.rs" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock x:Uid="BuiltFor" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                        <TextBlock Margin="5,0,0,0" x:Uid="FacultyName" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontWeight="SemiBold" Foreground="{ThemeResource ButtonForegroundThemeBrush}">
                            <interactivity:Interaction.Behaviors>
                                 <core:EventTriggerBehavior EventName="Tapped">
                                      <core:InvokeCommandAction
                                           Command="{Binding VisitDMICommand, Mode=OneWay}"/>
                                 </core:EventTriggerBehavior>
                            </interactivity:Interaction.Behaviors>
                        </TextBlock>
                    </StackPanel>
                </StackPanel>
                <StackPanel Margin="0,-10,0,5">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Tapped">
                            <core:InvokeCommandAction
                                    Command="{Binding VisitCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                    <TextBlock x:Uid="VisitMyWebSite" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock Text="http://nmilosev.svbtle.com" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                </StackPanel>
                <StackPanel Margin="0,-10,0,5">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Tapped">
                            <core:InvokeCommandAction
                                    Command="{Binding SendMailCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                    <TextBlock x:Uid="Feedback" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock x:Uid="SendEmail" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                </StackPanel>
                <StackPanel Margin="0,-10,0,5">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Tapped">
                            <core:InvokeCommandAction
                                    Command="{Binding OtherAppsCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                    <TextBlock x:Uid="MyOtherApps" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock Text="windows phone store" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                </StackPanel>
                <StackPanel Margin="0,-10,0,5">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Tapped">
                            <core:InvokeCommandAction
                                    Command="{Binding RateCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                    <TextBlock x:Uid="RateReview" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock Text="windows phone store" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                </StackPanel>
                <StackPanel Margin="0,-10,0,5">
                    <interactivity:Interaction.Behaviors>
                        <core:EventTriggerBehavior EventName="Tapped">
                            <core:InvokeCommandAction
                                    Command="{Binding ShareCommand, Mode=OneWay}"/>
                        </core:EventTriggerBehavior>
                    </interactivity:Interaction.Behaviors>
                    <TextBlock x:Uid="Share" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}" FontSize="24" Foreground="{ThemeResource ButtonForegroundThemeBrush}"/>
                    <TextBlock Text="facebook/twitter" TextWrapping="Wrap" Style="{StaticResource ControlHeaderTextBlockStyle}"/>
                </StackPanel>
            </ListBox>

        </PivotItem>
    </Pivot>



</Page>
